﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataControl;
using System.Data;
using System.Text;

namespace ATW.MT.BUS
{
    public class bus_C_FranLevel
    {
        DataAccess da = null;
        public bus_C_FranLevel()
        {
            da = new DataAccess();
        }
        #region 方法
        /// <summary>
        /// 法兰标准分页查询
        /// </summary>
        /// <param name="name"></param>
        /// <param name="page"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public DataTable FranPagerQuery(string name, int page, int pagesize)
        {
            string sql = "select * from [C_FranLevel] where rowstatus<>'2'";
            if (!String.IsNullOrEmpty(name))
            {
                sql += " and [desc] like '%" + name + "%'";
            }
            return da.PageSize(sql, page, pagesize, "FranLevelID","create_time desc");
        }
        /// <summary>
        /// 新增法兰标准
        /// </summary>
        /// <param name="desc"></param>
        /// <returns></returns>
        public int FranAdd(string desc)
        {
            string sql = "insert into [C_FranLevel] ([Desc])values('" + desc + "')";
            return da.ExcuteNoQuery(sql);
        }
        /// <summary>
        /// 修改法兰标准
        /// </summary>
        /// <param name="desc"></param>
        /// <param name="fid"></param>
        /// <returns></returns>
        public int FranEdit(string desc, string fid)
        {
            string sql = "update [C_FranLevel] set [desc]='" + desc + "' where [FranLevelID]='" + fid + "'";
            return da.ExcuteNoQuery(sql);
        }
        /// <summary>
        /// 法兰标准是否存在
        /// </summary>
        /// <param name="desc"></param>
        /// <returns></returns>
        public bool isFranExist(string desc)
        {
            string sql = "select * from C_FranLevel where [desc]='" + desc + "'";
            DataTable dt = da.ExecuteDataTable(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                return true;
            }
            return false;
        }
        #endregion
    }
}